// 引入Service和请求头ServiceName
import { Service, ServiceName } from '@/network/http.js'
import store from '@/store/index.js' // 引入store
const api = {
  /**
     * 获取作业指令著列表
     * @param {Object} params 检索条件的obj
     */
  reqGetOperation(params) {
    return Service.get(
      `/${ServiceName}/api/external/tBusTrust/queryall`,
      { params }
    )
  },
  /**
     * 新建作业指令
     * @param {Object} params billList:提单list，mAttachmentInfoList:上传附件list
     */
  reqAddTrust(params) {
    store.commit('changeStatus', true)
    return Service.post(
      `/${ServiceName}/api/external/tBusTrust/addTrust`,
      params
    )
  },
  /**
     * 修改作业指令
     * @param {Object} params billList:提单list，mAttachmentInfoList:上传附件list
     */
  reqUpdateTrust(params) {
    store.commit('changeStatus', true)
    return Service.post(
      `/${ServiceName}/api/external/tBusTrust/updateTrust`,
      params
    )
  },
  /**
     * 发布作业指令
     * @param {*} id 数据id
     */
  reqReleaseTrust(id) {
    store.commit('changeStatus', true)
    return Service.post(
      `/${ServiceName}/api/external/tBusTrust/releaseTrust?id=${id}`
    )
  },
  /**
     * 作业指令编辑查询
     * @param {Object} params id
     */
  reqEditTrust(id) {
    return Service.get(
      `/${ServiceName}/api/external/tBusTrust/queryById?id=${id}`
    )
  },
  /**
     * 根据船舶查货物信息
     * @param {String} id id
     */
  reqGetBillById(id) {
    return Service.get(
      `/${ServiceName}/api/external/tBusTrust/queryGroupBillByShipvoyageId?shipvoyageId=${id}`
    )
  },
  /**
   * 删除作业指令
   * @param {*} id 数据id
   */
  reqDeleteTrust(id) {
    return Service.delete(
      `/${ServiceName}/api/external/tBusTrust/deleteTrust?id=${id}`
    )
  },
  /**
     * 货权保存
     * @param {Object} params 检索条件的obj
     */
  reqSaveCargo(params) {
    store.commit('changeStatus', true)
    return Service.post(
      `/${ServiceName}/api/external/busCargoInfo/cargoOwnerTransfer`,
      params
    )
  },
  /**
   * 获取船名航次信息
   */
  getListShipvoyage() {
    return Service.get(
      `/${ServiceName}/api/external/tBusTrust/listShipvoyageAll`
    )
  }

}
export default api
